//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS IoTEventsData service.
///
/// IoT Events monitors your equipment or device fleets for failures or changes in operation, and triggers actions when such events occur. You can use IoT Events Data API commands to send inputs to detectors, list detectors, and view or update a detector's status. For more information, see What is IoT Events? in the IoT Events Developer Guide.
public struct IoTEventsData: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the IoTEventsData client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "IoTEventsData",
            serviceIdentifier: "data.iotevents",
            signingName: "ioteventsdata",
            serviceProtocol: .restjson,
            apiVersion: "2018-10-23",
            endpoint: endpoint,
            errorType: IoTEventsDataErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Acknowledges one or more alarms. The alarms change to the ACKNOWLEDGED state after you acknowledge them.
    @Sendable
    @inlinable
    public func batchAcknowledgeAlarm(_ input: BatchAcknowledgeAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchAcknowledgeAlarmResponse {
        try await self.client.execute(
            operation: "BatchAcknowledgeAlarm", 
            path: "/alarms/acknowledge", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Acknowledges one or more alarms. The alarms change to the ACKNOWLEDGED state after you acknowledge them.
    ///
    /// Parameters:
    ///   - acknowledgeActionRequests: The list of acknowledge action requests. You can specify up to 10 requests per operation.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchAcknowledgeAlarm(
        acknowledgeActionRequests: [AcknowledgeAlarmActionRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchAcknowledgeAlarmResponse {
        let input = BatchAcknowledgeAlarmRequest(
            acknowledgeActionRequests: acknowledgeActionRequests
        )
        return try await self.batchAcknowledgeAlarm(input, logger: logger)
    }

    /// Deletes one or more detectors that were created. When a detector is deleted, its state will be cleared and the detector will be removed from the list of detectors. The deleted detector will no longer appear if referenced in the ListDetectors API call.
    @Sendable
    @inlinable
    public func batchDeleteDetector(_ input: BatchDeleteDetectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchDeleteDetectorResponse {
        try await self.client.execute(
            operation: "BatchDeleteDetector", 
            path: "/detectors/delete", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes one or more detectors that were created. When a detector is deleted, its state will be cleared and the detector will be removed from the list of detectors. The deleted detector will no longer appear if referenced in the ListDetectors API call.
    ///
    /// Parameters:
    ///   - detectors: The list of one or more detectors to be deleted.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchDeleteDetector(
        detectors: [DeleteDetectorRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchDeleteDetectorResponse {
        let input = BatchDeleteDetectorRequest(
            detectors: detectors
        )
        return try await self.batchDeleteDetector(input, logger: logger)
    }

    /// Disables one or more alarms. The alarms change to the DISABLED state after you disable them.
    @Sendable
    @inlinable
    public func batchDisableAlarm(_ input: BatchDisableAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchDisableAlarmResponse {
        try await self.client.execute(
            operation: "BatchDisableAlarm", 
            path: "/alarms/disable", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Disables one or more alarms. The alarms change to the DISABLED state after you disable them.
    ///
    /// Parameters:
    ///   - disableActionRequests: The list of disable action requests. You can specify up to 10 requests per operation.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchDisableAlarm(
        disableActionRequests: [DisableAlarmActionRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchDisableAlarmResponse {
        let input = BatchDisableAlarmRequest(
            disableActionRequests: disableActionRequests
        )
        return try await self.batchDisableAlarm(input, logger: logger)
    }

    /// Enables one or more alarms. The alarms change to the NORMAL state after you enable them.
    @Sendable
    @inlinable
    public func batchEnableAlarm(_ input: BatchEnableAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchEnableAlarmResponse {
        try await self.client.execute(
            operation: "BatchEnableAlarm", 
            path: "/alarms/enable", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Enables one or more alarms. The alarms change to the NORMAL state after you enable them.
    ///
    /// Parameters:
    ///   - enableActionRequests: The list of enable action requests. You can specify up to 10 requests per operation.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchEnableAlarm(
        enableActionRequests: [EnableAlarmActionRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchEnableAlarmResponse {
        let input = BatchEnableAlarmRequest(
            enableActionRequests: enableActionRequests
        )
        return try await self.batchEnableAlarm(input, logger: logger)
    }

    /// Sends a set of messages to the IoT Events system. Each message payload is transformed into the input you specify ("inputName") and ingested into any detectors that monitor that input. If multiple messages are sent, the order in which the messages are processed isn't guaranteed. To guarantee ordering, you must send messages one at a time and wait for a successful response.
    @Sendable
    @inlinable
    public func batchPutMessage(_ input: BatchPutMessageRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchPutMessageResponse {
        try await self.client.execute(
            operation: "BatchPutMessage", 
            path: "/inputs/messages", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Sends a set of messages to the IoT Events system. Each message payload is transformed into the input you specify ("inputName") and ingested into any detectors that monitor that input. If multiple messages are sent, the order in which the messages are processed isn't guaranteed. To guarantee ordering, you must send messages one at a time and wait for a successful response.
    ///
    /// Parameters:
    ///   - messages: The list of messages to send. Each message has the following format: '{ "messageId": "string", "inputName": "string", "payload": "string"}'
    ///   - logger: Logger use during operation
    @inlinable
    public func batchPutMessage(
        messages: [Message],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchPutMessageResponse {
        let input = BatchPutMessageRequest(
            messages: messages
        )
        return try await self.batchPutMessage(input, logger: logger)
    }

    /// Resets one or more alarms. The alarms return to the NORMAL state after you reset them.
    @Sendable
    @inlinable
    public func batchResetAlarm(_ input: BatchResetAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchResetAlarmResponse {
        try await self.client.execute(
            operation: "BatchResetAlarm", 
            path: "/alarms/reset", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Resets one or more alarms. The alarms return to the NORMAL state after you reset them.
    ///
    /// Parameters:
    ///   - resetActionRequests: The list of reset action requests. You can specify up to 10 requests per operation.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchResetAlarm(
        resetActionRequests: [ResetAlarmActionRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchResetAlarmResponse {
        let input = BatchResetAlarmRequest(
            resetActionRequests: resetActionRequests
        )
        return try await self.batchResetAlarm(input, logger: logger)
    }

    /// Changes one or more alarms to the snooze mode. The alarms change to the SNOOZE_DISABLED state after you set them to the snooze mode.
    @Sendable
    @inlinable
    public func batchSnoozeAlarm(_ input: BatchSnoozeAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchSnoozeAlarmResponse {
        try await self.client.execute(
            operation: "BatchSnoozeAlarm", 
            path: "/alarms/snooze", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Changes one or more alarms to the snooze mode. The alarms change to the SNOOZE_DISABLED state after you set them to the snooze mode.
    ///
    /// Parameters:
    ///   - snoozeActionRequests: The list of snooze action requests. You can specify up to 10 requests per operation.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchSnoozeAlarm(
        snoozeActionRequests: [SnoozeAlarmActionRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchSnoozeAlarmResponse {
        let input = BatchSnoozeAlarmRequest(
            snoozeActionRequests: snoozeActionRequests
        )
        return try await self.batchSnoozeAlarm(input, logger: logger)
    }

    /// Updates the state, variable values, and timer settings of one or more detectors (instances) of a specified detector model.
    @Sendable
    @inlinable
    public func batchUpdateDetector(_ input: BatchUpdateDetectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> BatchUpdateDetectorResponse {
        try await self.client.execute(
            operation: "BatchUpdateDetector", 
            path: "/detectors", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates the state, variable values, and timer settings of one or more detectors (instances) of a specified detector model.
    ///
    /// Parameters:
    ///   - detectors: The list of detectors (instances) to update, along with the values to update.
    ///   - logger: Logger use during operation
    @inlinable
    public func batchUpdateDetector(
        detectors: [UpdateDetectorRequest],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> BatchUpdateDetectorResponse {
        let input = BatchUpdateDetectorRequest(
            detectors: detectors
        )
        return try await self.batchUpdateDetector(input, logger: logger)
    }

    /// Retrieves information about an alarm.
    @Sendable
    @inlinable
    public func describeAlarm(_ input: DescribeAlarmRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribeAlarmResponse {
        try await self.client.execute(
            operation: "DescribeAlarm", 
            path: "/alarms/{alarmModelName}/keyValues", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves information about an alarm.
    ///
    /// Parameters:
    ///   - alarmModelName: The name of the alarm model.
    ///   - keyValue: The value of the key used as a filter to select only the alarms associated with the
    ///   - logger: Logger use during operation
    @inlinable
    public func describeAlarm(
        alarmModelName: String,
        keyValue: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribeAlarmResponse {
        let input = DescribeAlarmRequest(
            alarmModelName: alarmModelName, 
            keyValue: keyValue
        )
        return try await self.describeAlarm(input, logger: logger)
    }

    /// Returns information about the specified detector (instance).
    @Sendable
    @inlinable
    public func describeDetector(_ input: DescribeDetectorRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribeDetectorResponse {
        try await self.client.execute(
            operation: "DescribeDetector", 
            path: "/detectors/{detectorModelName}/keyValues", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns information about the specified detector (instance).
    ///
    /// Parameters:
    ///   - detectorModelName: The name of the detector model whose detectors (instances) you want information about.
    ///   - keyValue: A filter used to limit results to detectors (instances) created because of the given key ID.
    ///   - logger: Logger use during operation
    @inlinable
    public func describeDetector(
        detectorModelName: String,
        keyValue: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribeDetectorResponse {
        let input = DescribeDetectorRequest(
            detectorModelName: detectorModelName, 
            keyValue: keyValue
        )
        return try await self.describeDetector(input, logger: logger)
    }

    /// Lists one or more alarms. The operation returns only the metadata associated with each alarm.
    @Sendable
    @inlinable
    public func listAlarms(_ input: ListAlarmsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListAlarmsResponse {
        try await self.client.execute(
            operation: "ListAlarms", 
            path: "/alarms/{alarmModelName}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists one or more alarms. The operation returns only the metadata associated with each alarm.
    ///
    /// Parameters:
    ///   - alarmModelName: The name of the alarm model.
    ///   - maxResults: The maximum number of results to be returned per request.
    ///   - nextToken: The token that you can use to return the next set of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listAlarms(
        alarmModelName: String,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListAlarmsResponse {
        let input = ListAlarmsRequest(
            alarmModelName: alarmModelName, 
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listAlarms(input, logger: logger)
    }

    /// Lists detectors (the instances of a detector model).
    @Sendable
    @inlinable
    public func listDetectors(_ input: ListDetectorsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListDetectorsResponse {
        try await self.client.execute(
            operation: "ListDetectors", 
            path: "/detectors/{detectorModelName}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists detectors (the instances of a detector model).
    ///
    /// Parameters:
    ///   - detectorModelName: The name of the detector model whose detectors (instances) are listed.
    ///   - maxResults: The maximum number of results to be returned per request.
    ///   - nextToken: The token that you can use to return the next set of results.
    ///   - stateName: A filter that limits results to those detectors (instances) in the given state.
    ///   - logger: Logger use during operation
    @inlinable
    public func listDetectors(
        detectorModelName: String,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        stateName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListDetectorsResponse {
        let input = ListDetectorsRequest(
            detectorModelName: detectorModelName, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            stateName: stateName
        )
        return try await self.listDetectors(input, logger: logger)
    }
}

extension IoTEventsData {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: IoTEventsData, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
